﻿@model ITProject.WebUI.Models.ProjectUser.ProjectUserCalenderViewModel
@{
    ViewBag.Title = "Kalendarz";
    Layout = "~/Views/Shared/_Layout.cshtml";
}



<h2>Panel uczestnika projektu @Html.Encode(Model.projectName)</h2>

<div class="Pmenu">
@Html.Partial(MVC.Shared.Views.Partials._ProjectMenuControl,
        new ITProject.WebUI.Models.Project.ProjectMenuViewModel { ProjectName = Model.projectName, Role = (ITProject.Domain.UserRole)ViewData["Role"] })
</div>



<div class="PAmenu">
@Html.Partial(MVC.Shared.Views.Partials._ProjectUserMenu, new List<string> {"K",Model.projectName })
@*@Html.ActionLink("Zarządzaj użytkownikami",MVC.ProjectAdmin.ActionNames.ManageTeam, MVC.ProjectAdmin.Name, new { projectName = Model }, null)*@
</div>
<div class="PAplane">
<span class="zmien">
Zmien widok na:   <span class="button" id="butCal" style="display:none">Kalendarz</span> <span id="butTab" class="button">Tablica</span>
</span>
<div id="kalendarz">
<span id="infomoje" style="font-size:smaller; text-align:center; display:none">Wyświetlasz tylko wydarzenia dotyczące Ciebie</span>
<table width="100%" class="inbox">
        <thead>
        <tr>
            <td colspan="7"> <span class="buttonS" id="all" width="90px">Wszystkie</span> <span class="buttonPop" >Poprzedni</span> @Html.DropDownList("interv", Model.ListWeek, new { @class="input", @id="intervlist"}) <span class="buttonNast" >Następny</span> <span class="buttonS" id="my">Tylko moje</span></td>
        </tr>
        <tr>
        <th width="14%">Poniedziałek</th>
        <th width="14%">Wtorek</th>
        <th width="14%">Środa</th>
        <th width="14%">Czwartek</th>
        <th width="14%">Piątek</th>
        <th width="14%">Sobota</th>
        <th width="14%">Niedziela</th>
        </tr>
        </thead>
        <tbody>
@foreach (var itemWeek in Model.projectEventweek)
{

          var id1 = "interv" + itemWeek.id;
          var id2 = "days" + itemWeek.id;
            string display;
            if (itemWeek.id != Model.idthisWeek)
            {
                display = "display:none";
            }
            else
            {
                display = "display:table-row";
            }
    
    <tr class="interv" id=@id1 style=@display>
    <td colspan="7" class="label" style="text-align:center">
        @itemWeek.DateInterval
    </td>
    </tr>
    <tr class="days" id=@id2 style=@display>
        @{  int i = 0; 
           int dzien=1; 
            }
        
        @while (dzien!=1 || i==0)
        {
            <td class="CalDzien">
           
            @while (itemWeek.ProjectEvent.Count > i && (int)itemWeek.ProjectEvent.ToList()[i].EndDate.DayOfWeek== dzien)
            {
                var iteeem=itemWeek.ProjectEvent.ToList()[i];
                string kolor;
                string borderKolor;
                if (iteeem.TypeEvent == "Release")
                {
                    kolor = "#e89191";
                }
                else
                {
                    if (iteeem.TypeEvent == "Feature")
                    {
                        kolor = "#91e8a9";
                        
                    }
                    else
                    {
                        kolor = "#91ace8";
                    }
                }
                if (iteeem.Status == "Zaakceptowany")
                {
                    borderKolor = "#000000";
                }
                else
                {
                    if (iteeem.Status == "Przetestowany")
                    {
                        borderKolor = "#9395a0";
                    }
                    else
                    {
                        if (iteeem.Status == "Wykonany")
                        {
                            borderKolor = "#2a48ed";
                        }
                        else
                        {
                            if (iteeem.Status == "Aktywny")
                            {
                                borderKolor = "#FF0000";
                            }
                            else
                            {
                                borderKolor = "#edcf2a";
                            }
                        }
                        
                    }
                }
                
                
                var styl = "background-color:" + kolor+";border-color:"+borderKolor;
                string classs;
                if (iteeem.Receiver == User.Identity.Name)
                {
                    classs="DaycallM";
                }else
                {
                    classs="DaycallN";
                }
                <span style=@styl class=@classs>
                <b>@iteeem.Name</b><br />
                <i>@iteeem.Receiver<br />
                @if (iteeem.istoTeam != null && iteeem.istoTeam)
                {
                    @:(zespoł)
                }
                (@iteeem.Belongs)
                </i>
                </span><br />  
            i++;
            }
            @if(dzien<6)
            {
                dzien++;
            }else
            {
                dzien=0;
            }
        
        
        
   </td>
        }
    </tr>    

}       
 </tbody>

    </table>
    <fieldset>
    <legend> Legenda</legend>
    <span class="legend">
    <b>Zdarzenia: </b> <br />
    <span class="rect" style="background-color:#e89191"></span> Wersja<br />
    <span class="rect" style="background-color:#91e8a9"></span> Funkcjonalność<br />
    <span class="rect" style="background-color:#91ace8"></span> Zadanie<br />
    </span>
    <span class="legend">
    <b>Statusy: </b> <br />
    <span class="rect" style="border-color:#FF0000;border-style:solid;border-width:2px;"></span> Aktywny<br />
    <span class="rect" style="border-color:#edcf2a;border-style:solid;border-width:2px;"></span> Planowany<br />
    <span class="rect" style="border-color:#2a48ed;border-style:solid;border-width:2px;"></span> Wykonany<br />    
    <span class="rect" style="border-color:#9395a0;border-style:solid;border-width:2px;"></span> Przetestowany<br />  
    <span class="rect" style="border-color:#000000;border-style:solid;border-width:2px;"></span> Zaakceptowany<br />  
    </span>

    </fieldset>
    
    </div>

    <div id="Tablica" style="display:none">
    <span class="button" id="ff">Filtry</span>
    <span class="lista">
    <fieldset>
    <legend>Wyszukiwarka</legend>
    Wyszukaj po nazwie: @Html.TextBox("nazwa", "", new { @class="input" , @style="width:350px", @id="szukajKal"}) <span id="clear" class="button">Czyść</span>
    </fieldset>
    <fieldset>
    <legend>Filtry</legend>
    
    <span style="display:inline-block">
    Typ<br />
    @Html.ListBox("Typ", Model.Type, new { @id="typ"})
    </span>
    <span style="display:inline-block">
    Status<br />
    @Html.ListBox("Status", Model.Status, new { @id="stat"})
    </span>
        <span style="display:inline-block">
    Priorytet<br />
    @Html.ListBox("Priorytet", Model.Priority, new { @id="pr"})
    </span>

     <span style="display:inline-block">
    Użytkownicy<br />
    @Html.ListBox("Użytkownicy", Model.Users, new { @id="us"})
    </span>
        <span style="display:inline-block">
    Zespoły<br />
    @Html.ListBox("Zespoły", Model.Teams, new { @id="zs"})
    </span>
    <span style="display:inline-block">
    Wersja<br />
    @Html.ListBox("Wersja", Model.Releases, new { @id="wer"})
    </span>
    

    <span style="display:inline-block">
    Funkcjonalność<br />
    @Html.ListBox("Funkcjonalnosc", Model.Features, new { @id="funk"})
    </span>
   </fieldset></span>
    <table class="inbox" id="users">
    <thead>
    <tr>
    <th class="label" width="100px">Nazwa</th>
    <th class="label" width="100px">Typ</th>
    <th class="label" width="100px">Status</th>
    <th class="label"width="80px" >Priorytet</th>
    <th  class="label"style="display:none">Przypisany do</th>
    <th class="label" width="100px">Wykonawca</th>
    <th class="label" width="100px">Planowana data wykonania</th>
    </tr>
    </thead>
    <tbody>
    @foreach (var t in Model.projectEventweek)
    {
        foreach (var e in t.ProjectEvent)
         {
             
             <tr>
             <td class="edit">@e.Name</td>
             <td class="edit">@e.TypeEvent</td>
             <td class="edit">@e.Status</td>
             <td class="edit">@e.Priority</td>
             <td class="edit" style="display:none">@e.Belongs</td>
             <td class="edit">@e.Receiver</td>
             <td class="edit">@e.EndDate.ToString("yyyy/MM/dd")</td>
             <td style="display:none">@e.istoTeam</td>
             </tr>
         }
    }
    
    </tbody>
    </table>
    </div>
    
</div>
<div class="clear">
</div>
